using System;
#if NETFX_CORE
using Windows.UI.Xaml.Markup;
#else
using System.Windows.Markup;
#endif



namespace Prometheus.Binding.Validation.Rules.Advanced
{
    [ContentProperty(
#if NETFX_CORE
        Name=
#endif
        "InvertedRule")]
    public class proInvertedValidationRule : proValidationRuleBase
    {
        public IValidationRule InvertedRule { get; set; }

        public override void Validate(object value, object dataContext)
        {
            if (InvertedRule == null) throw new InvalidOperationException("It is neccessary to provide inverted rule");

            try
            {
                InvertedRule.Validate(value, dataContext);
            }
            catch (proValidationException)
            {
                return;
            }
            ThrowInvalid();
        }
    }
}